﻿using System;
using System.IO;

class DirAppend
{
    //public static void Main()
    //{
    //    using (StreamWriter w = File.AppendText("log.txt"))
    //    {
    //        Log("Test1", w);
    //        Log("Test2", w);
    //    }

    //    using (StreamReader r = File.OpenText("log.txt"))
    //    {
    //        DumpLog(r);
    //    }
    //}

    public static void Log(string logMessage, TextWriter w)
    {
        //using (StreamWriter w = File.AppendText("log.txt"))
        {
            w.Write("\r\nLog Entry : ");
            w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
                DateTime.Now.ToLongDateString());
            w.WriteLine("  :");
            w.WriteLine("  :{0}", logMessage);
            w.WriteLine("-------------------------------");
        }
    }

    public static void DumpLog(StreamReader r)
    {
        string line;
        while ((line = r.ReadLine()) != null)
        {
            Console.WriteLine(line);
        }
    }
}